package com.siss.tenancy.util;

import java.text.DecimalFormat;

public class Double2DefineDecimalUtil {

	public static Double getDefineDecimal(Double num,Integer length){
		Double retNum = 0.00;
		if(null == length || 1 >= length){
			length = 2;
		}
		String zeroLen = "";
		for(int i = 0; i < length; i++){
			zeroLen += 0;
		}
		 DecimalFormat Format=new DecimalFormat("#."+zeroLen); 
		 String str=Format.format(num);  
		 retNum= Double.valueOf(str);
		 System.err.println(retNum);
		return retNum;
	}
	
	public static void main(String[] args) {
		getDefineDecimal(1599.8899999999999,null);
	}
}
